package com.ruoyi.hotel.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.hotel.domain.InvoiceInfo;
import com.ruoyi.hotel.domain.LyhmsOrder;
import com.ruoyi.hotel.mapper.InvoiceInfoMapper;
import com.ruoyi.hotel.mapper.LyhmsOrderMapper;
import com.ruoyi.hotel.service.IInvoiceInfoService;
import com.ruoyi.system.mapper.SysDeptMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * Service业务层处理
 * @author ruoyi
 * @date 2022-03-03
 */
@Service
public class InvoiceInfoServiceImpl implements IInvoiceInfoService {
    @Resource
    private InvoiceInfoMapper invoiceInfoMapper;
    @Resource
    private SysDeptMapper sysDeptMapper;
    @Resource
    private LyhmsOrderMapper lyhmsOrderMapper;

    /**
     * 查询
     * @param id 主键
     * @return
     */
    @Override
    public InvoiceInfo selectInvoiceInfoById(String id) {
        return invoiceInfoMapper.selectInvoiceInfoById(id);
    }

    /**
     * 查询列表
     * @param invoiceInfo
     * @return
     */
    @Override
    public List<InvoiceInfo> selectInvoiceInfoList(InvoiceInfo invoiceInfo) {
        return invoiceInfoMapper.selectInvoiceInfoList(invoiceInfo);
    }

    /**
     * 新增
     * @param invoiceInfo
     * @return 结果
     */
    @Override
    public int insertInvoiceInfo(InvoiceInfo invoiceInfo) {
        invoiceInfo.setHotelName("希尔顿欢朋宾馆");
        invoiceInfo.setPhone("17854337865");
        invoiceInfo.setAccountNum("234235453345345");
        invoiceInfo.setIdentifyNumber("wewe23452353234");
        invoiceInfo.setDrawer("王三");
        invoiceInfo.setCreateTime(DateUtils.getNowDate());
        int row = invoiceInfoMapper.insertInvoiceInfo(invoiceInfo);
        LyhmsOrder lyhmsOrder = lyhmsOrderMapper.selectLyhmsOrderById(invoiceInfo.getOrderId());
        lyhmsOrder.setCheckInStatus("4");
        lyhmsOrderMapper.updateLyhmsOrder(lyhmsOrder);
        return row;
    }

    /**
     * 修改
     * @param invoiceInfo
     * @return 结果
     */
    @Override
    public int updateInvoiceInfo(InvoiceInfo invoiceInfo) {
        return invoiceInfoMapper.updateInvoiceInfo(invoiceInfo);
    }

    /**
     * 批量删除
     * @param ids 需要删除的主键
     * @return 结果
     */
    @Override
    public int deleteInvoiceInfoByIds(String[] ids) {
        return invoiceInfoMapper.deleteInvoiceInfoByIds(ids);
    }

    /**
     * 删除信息
     * @param id 主键
     * @return 结果
     */
    @Override
    public int deleteInvoiceInfoById(String id) {
        return invoiceInfoMapper.deleteInvoiceInfoById(id);
    }
}
